package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.controller.request.RecordPageRequest;
import com.example.springboot.entity.Record;
import com.example.springboot.service.IRecordService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

@CrossOrigin
@RestController
@RequestMapping("/record")
public class RecordController {

    @Autowired
    IRecordService recordService;

    @GetMapping("/list")
    public List<Record> listRecords() {
        return recordService.listRecords();
    }

    @GetMapping("/page")
    public Result page(RecordPageRequest recordPageRequest) {
        return (Result) Result.success(recordService.page(recordPageRequest));

    }

    @PostMapping("/add")
    public Result add(@RequestBody Record record) {
        recordService.add(record);
        return Result.success();
    }

}
